﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace XGameFrame.Controls
{
    public class LinkLabel:Control
    {

        #region Fields and Properties

        Color selectedColor = Color.Red;
        public Color SelectedColor
        {
            get { return selectedColor; }
            set { selectedColor = value; }
        }

        #endregion

        #region Constructor Region

        public LinkLabel(Vector2 pPosition,String pText)
            :base(pPosition)
        {
            TabStop = true;
            HasFocus = false;
            Text = pText;
            Size = getSizeForText(pText);
            Bounds = new Rectangle((int)Position.X, (int)Position.Y, (int)Size.X, (int)Size.Y);
            //UpdateBoundPositions();
        }

        #endregion

        #region Abstract Methods

        public override void Update(GameTime gameTime)
        {
            
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (hasFocus)
                spriteBatch.DrawString(SpriteFont, Text, Position, selectedColor);
            else
                spriteBatch.DrawString(SpriteFont, Text, Position, Color);
        }
        public override void HandleInput(PlayerIndex playerIndex)
        {
            if (!HasFocus)
                return;
            if (InputHandler.KeyReleased(Keys.Enter) ||
                InputHandler.ButtonReleased(Buttons.A, playerIndex))
                base.OnSelected(null);
        }

        public override void OnHover(PlayerIndex playerIndex)
        {
            if (!HasFocus)
                return;
            if (InputHandler.MouseButtonLeftPressed())
                base.OnSelected(null);
        }

        #endregion


    }
}
